home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4114 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.9 KB  |  48 lines

  1. Newsgroups: comp.os.ms-windows.programmer.tools.mfc,comp.os.ms-windows.apps.compatibility.win95,comp.lang.c++
  2. Path: newsfeed.internetmci.com!miwok!linex1!news
  3. From: mfried@linex.com (Marty Fried)
  4. Subject: Re: HELP - CString conversion?
  5. X-Nntp-Posting-Host: sp67.linex.com
  6. Message-ID: <310ae342.2323507@news.linex.com>
  7. Sender: news@linex1.linex.com
  8. Organization: Cirrius Cybernetics Corp
  9. X-Newsreader: Forte Agent .99d/32.179
  10. References: <NEWTNews.16531.822443361.Postmaster@Jerusalem.netvision.net.il>
  11. Date: Sun, 28 Jan 1996 02:48:15 GMT
  12.  
  13. Once upon a time (OK, it was Tue, 23 Jan 96 16:26:35 PDT),
  14. iti@Jerusalem.netvision.net.il wrote:
  15. >When I try to read the text from a Edit Control (IDC_EDIT1) with the
  16. >following code:
  17. >
  18. >--------------------------------------------------------------
  19. >CString callBuf;
  20. >int msgLen = GetDlgItemText(IDC_EDIT1, callBuf, sizeof(callBuf));
  21. >--------------------------------------------------------------
  22. >
  23. >I get the following error:
  24. >
  25. >--------------------------------------------------------------
  26. >error C2664: 'GetDlgItemText' : cannot convert parameter 2 from 'class 
  27.  
  28. >::CString ' to 'char __far *'
  29. >--------------------------------------------------------------
  30. >
  31. >
  32. >I am using Visual C++, how can I read the text directly into the CString?
  33. >I know that I am doing something REAL STUPID so if you can be of any help-
  34. >
  35. >Please send any advice you have for me to my EMail address:
  36. cc:    iti@netvision.net.il
  37.  
  38. You can use a CString directly only if the function calls for a
  39. constant char * (LPCSTR).  Otherwise, you can call
  40. CString::GetBuffer(), which will return a pointer that you can modify;
  41. but you must later call ReleaseBuffer() if you do indeed change it.
  42. This is clearly explained in the documentation for CString.
  43.  
  44. _______________________________________________________
  45. Marty Fried - mfried@linex.com     Press Enter to Exit
  46. San Anselmo, CA                           -NT message
  47. (MSVC4 + MFC) && (Win95 || NT);             
  48.